<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
</head>

<body>
    学号：
    <input type="text" id="snInput">
    名字：
    <input type="text" id="nameInput">
    电话：
    <input type="text" id="telInput">
    <button onclick="register()">确认注册</button>
</body>
<script>
    function register() {
        var myHeaders = new Headers();
        myHeaders.append("Content-type", "application/json");

        var raw = JSON.stringify({
            "Name": document.getElementById("nameInput").value,
            "Sn": document.getElementById("snInput").value,
            "Tel": document.getElementById("telInput").value,
        });

        var requestOptions = {
            method: 'POST',
            headers: myHeaders,
            body: raw,
            redirect: 'follow'
        };

        fetch("https://study.godoai.com/api/user/register", requestOptions)
           .then(response => response.json())
           .then(result => {
                // 注册成功后 提示用户
                if (result.Code == 1000) {
                    alert("注册成功")
                } else {
                    alert("注册失败")
                }
            })
           .catch(error => console.log('error', error));
    }
</script>

</html>